﻿FROM ubuntu:16.04
MAINTAINER ElliotXX "https://github.com/elliotxx"

# 拷贝当前目录到镜像中
WORKDIR /root/
COPY . /root/douyin_back/

# 拷贝 pip 配置文件
COPY ./docker/pip.conf .pip/pip.conf

# 安装python3.6必要的包，以及一些常用工具
RUN apt-get update
RUN apt-get install -y vim wget htop software-properties-common 

# 安装语言包
RUN apt-get install -y locales

# Ensure that we always use UTF-8 and with Canadian English locale
RUN locale-gen en_CA.UTF-8

# 安装python3.6 from 第三方
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y python3.6 python3.6-dev

# 安装pip3
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3.6 get-pip.py

# 和自带的3.5共存
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
RUN update-alternatives --config python

# 安装 django uwsgi 等项目依赖
WORKDIR /root/douyin_back
RUN apt-get install -y uwsgi
RUN apt-get install -y gcc build-essential make
RUN pip3 install -r requirements.txt

# 覆盖 wsgi 配置和启动脚本为 docker 版本
COPY ./docker/uwsgi.ini ./uwsgi.ini
COPY ./docker/uwsgiserver.sh ./uwsgiserver.sh

# print()时在控制台显示中文
ENV PYTHONIOENCODING=utf-8

# support Chinese
ENV LC_ALL=en_CA.UTF-8
ENV LANG=en_CA.UTF-8
ENV LANGUAGE=en_CA.UTF-8

# 暴露的端口
EXPOSE 8004

# 启动服务
CMD uwsgi --ini uwsgi.ini

